<!-- xuwencheng  2022年6年29日18:00  这是我的wenzhangbianji -->
<!-- 编辑 -->
<template>
  <el-dialog
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    :destory-on-close="true"
    :title="title"
    :visible.sync="dialogFormVisible"
    width="65%"
    @close="close"
  >
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="实名信息" name="first">
        <el-form ref="form" label-width="200px" :model="form">
          <el-form-item label="数字id" prop="digitalId">
            <span>{{ form.digitalId }}</span>
          </el-form-item>
          <el-form-item label="姓名" prop="name">
            <span>{{ form.userName }}</span>
          </el-form-item>
          <el-form-item label="手机号" prop="phone">
            <span>{{ form.phone }}</span>
          </el-form-item>

          <el-form-item label="身份证正面">
            <img v-if="shfenone" class="avatar" disabled :src="shfenone" />
          </el-form-item>
          <el-form-item label="身份证反面">
            <img v-if="shfentwo" class="avatar" disabled :src="shfentwo" />
          </el-form-item>
          <el-form-item v-if="form.realName == 2" label="审核状态">
            <span>审核通过</span>
          </el-form-item>
          <el-form-item v-if="form.realName == 1" label="审核状态">
            <span>审核中</span>
          </el-form-item>
        </el-form>
        <el-form
          v-if="form.realName == 0 || form.realName == 3"
          ref="formthree"
          label-width="200px"
          :model="formthree"
          :rules="rulesTWO"
          style="text-align: center"
        >
          <el-form-item
            label="审核状态"
            prop="checkValue"
            style="display: inline-block"
          >
            <el-select
              v-model="formthree.checkValue"
              placeholder="请选择审核状态"
            >
              <el-option
                v-for="item in options6"
                :key="item.id"
                clearable
                :label="item.creClasName"
                :value="item.id"
                @click.native="optosallTWO(item)"
              />
            </el-select>
          </el-form-item>
          <el-form-item
            v-if="formthree.checkValue == 0"
            label="驳回原因"
            prop="rejectReason"
          >
            <el-input
              v-model="formthree.rejectReason"
              placeholder="请输入驳回原因"
            />
          </el-form-item>
        </el-form>
        <el-button
          class="baocun"
          size="medium"
          type="primary"
          @click="saveTW('formthree')"
        >
          保存
        </el-button>
        <!-- 演员认证信息 -->
      </el-tab-pane>
      <el-tab-pane label="领队认证信息" name="second">
        <el-form ref="form" label-width="200px" :model="form">
          <el-form-item label="姓名" prop="userName">
            {{ form.userName }}
          </el-form-item>
          <el-form-item label="领队名称" prop="leaNickName">
            {{ form.leaNickName }}
          </el-form-item>
          <el-form-item v-if="form.authEnterprise == 0" label="是否是企业">
            <span>个人</span>
          </el-form-item>
          <el-form-item v-if="form.authEnterprise == 1" label="是否是企业">
            <span>企业</span>
          </el-form-item>
          <el-form-item
            v-if="form.authEnterprise == 1"
            label="营业执照"
            prop="enterpriseLicense"
          >
            <img v-if="shfenthree" class="avatar" disabled :src="shfenthree" />
          </el-form-item>
          <el-form-item label="所属公司" prop="ofEnterprise">
            {{ form.ofEnterprise }}
          </el-form-item>
          <el-form-item label="领队简介" prop="leaderIntro">
            {{ form.leaderIntro }}
          </el-form-item>
        </el-form>
        <el-form
          ref="formtwo"
          label-width="200px"
          :model="formtwo"
          :rules="rules"
          style="text-align: center"
        >
          <el-form-item
            v-if="form.authLeader == 0"
            label="当前审核状态"
            style="display: inline-block"
          >
            <span>未认证</span>
          </el-form-item>
          <el-form-item
            v-if="form.authLeader == 1"
            label="当前审核状态"
            style="display: inline-block"
          >
            <span>待审核</span>
          </el-form-item>
          <el-form-item
            v-if="form.authLeader == 2"
            label="当前审核状态"
            style="display: inline-block"
          >
            <span>审核通过</span>
          </el-form-item>
          <el-form-item
            v-if="form.authLeader == 3"
            label="当前审核状态"
            style="display: inline-block"
          >
            <span>审核未通过</span>
          </el-form-item>
          <el-form-item
            label="审核状态"
            prop="checkValue"
            style="display: inline-block"
          >
            <el-select
              v-model="formtwo.checkValue"
              placeholder="请选择审核状态"
            >
              <el-option
                v-for="item in options5"
                :key="item.id"
                clearable
                :label="item.creClasName"
                :value="item.id"
                @click.native="optosall(item)"
              />
            </el-select>
          </el-form-item>
          <el-form-item
            v-if="formtwo.checkValue == 0"
            label="驳回原因"
            prop="rejectReason"
          >
            <el-input
              v-model="formtwo.rejectReason"
              placeholder="请输入驳回原因"
            />
          </el-form-item>
        </el-form>
        <el-button
          class="baocun"
          size="medium"
          type="primary"
          @click="save('formtwo')"
        >
          保存
        </el-button>
      </el-tab-pane>
    </el-tabs>
  </el-dialog>

  <!-- 增加 -->
</template>

<script>
  /* eslint-disable*/
  import { check, geturl } from '@/api/lingdui'

  export default {
    name: 'search',

    data() {
      return {
        idCardFront: '', //正面
        idCardReverse: '', //范面
        yingye: '', //营业执照
        shfenone: '', //身份证整
        shfentwo: '', //身份证反面
        shfenthree: '', //营业执照
        activeName: 'first', //默认展示第一项
        token: '',
        imageUrl: '',
        options5: [
          {
            id: 1,
            creClasName: '审核通过',
          },
          {
            id: 0,
            creClasName: '审核未通过',
          },
        ], //身份
        options1: [
          {
            id: 1,
            creClasName: '审核通过',
          },
          {
            id: 0,
            creClasName: '审核未通过',
          },
        ], //审核状态
        options6: [
          {
            id: 1,
            creClasName: '审核通过',
          },
          {
            id: 0,
            creClasName: '审核未通过',
          },
        ],
        form: {
          checkValue: '', //审核的结果0未通过1通过
          rejectReason: '', //审核未通过时驳回原因
          starUserId: 1, //移动端用户id 传过来的id
          beCheckedId: 1, //被审核的数据的id 选项的id
        },
        formtwo: {
          checkValue: '', //审核的结果0未通过1通过
          rejectReason: '', //审核未通过时驳回原因
          starUserId: 1, //移动端用户id 传过来的id
          beCheckedId: 1, //被审核的数据的id 选项的id
        },
        formthree: {
          starUserId: 683, //移动端用户id
          checkValue: '', //审核的结果
          rejectReason: '', //拒绝原因
        },
        activated() {
          if (this.$refs.MaskVideo.src) this.$refs.MaskVideo.play()
        },
        deactivated() {
          if (this.$refs.MaskVideo.src) this.$refs.MaskVideo.pause()
        },

        rules: {
          rejectReason: [
            { required: true, trigger: 'blur', message: '请输入驳回原因' },
          ],
          checkValue: [
            { required: true, trigger: 'change', message: '请选择审核状态' },
          ],
        },
        title: '',
        dialogFormVisible: false,
      }
    },
    methods: {
      optosallTWO(e) {
        //实名审核
        this.formthree.checkValue = e.id
      },
      saveTW(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            console.log(this.formthree)
            const msg = checktwo(this.formthree)
            msg.then((res) => {
              this.$baseMessage(res.msg, 'success', 'vab-hey-message-success')
              this.$emit('fetch-data')
              this.closetwo()
            })
          } else {
            return false
          }
        })
      },
      showEdit(row) {
        if (!row) {
          this.title = '添加'
        } else {
          this.title = '处理'
          this.form = Object.assign({}, row)
          this.form.authEnterprise = String(row.authEnterprise)
          this.formthree.starUserId = row.userId
          this.dialogFormVisible = true
          this.formtwo.starUserId = row.userId
          this.formtwo.beCheckedId = row.id
          this.idCardReverse = row.idCardReverse
          this.idCardFront = row.idCardFront
          this.yingye = row.enterpriseLicense
          this.geturltwo()
          this.geturlone()
          this.geturlthree()
        }
      },
      optosall(e) {
        this.formtwo.checkValue = e.id
      },
      close() {
        let userId = this.form.userId
        this.$refs['form'].resetFields()
        this.form = this.$options.data().form
        if (!this.form.id) {
          this.form.userId = userId
        }
        this.dialogFormVisible = false
        this.imageUrl = ''
        // this.form = ''
      },
      handleClick(tab, event) {},
      closetwo() {
        this.formtwo.checkValue = ''
        this.formtwo.rejectReason = ''
        this.dialogFormVisible = false
      },
      save(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            const msg = check(this.formtwo)
            msg.then((res) => {
              this.$emit('fetch-data')
              if (res.msg == '修改成功') {
                this.$baseMessage(res.msg, 'success', 'vab-hey-message-success')
              }
              this.close()
            })
          } else {
            return false
          }
        })
      },
      async geturlone() {
        const res = await geturl({
          f: this.idCardFront,
        })
        this.shfenone = res
      },
      async geturltwo() {
        const res = await geturl({
          f: this.idCardReverse,
        })
        this.shfentwo = res
      },
      async geturlthree() {
        const res = await geturl({
          f: this.yingye,
        })
        this.shfenthree = res
      },
      nickNameChange() {
        this.$forceUpdate()
      },
    },
  }
</script>
<style>
  .avatar-uploader .el-upload {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409eff;
  }
  .avatar-uploader-icon {
    width: 178px;
    height: 178px;
    font-size: 28px;
    line-height: 178px;
    color: #8c939d;
    text-align: center;
  }
  .avatar {
    display: block;
    width: 178px;
    height: 178px;
  }
  .baocun {
    width: 100%;
    height: 100%;
  }
</style>
